<template>
  <div class="box">
    <!-- <el-card> -->
      <div class="header">
        <el-input v-model="input" placeholder="输入道路名称"></el-input>
        <div class="img">
          <img src="@/assets/images/u87.svg" alt="" @click="imgu87" />
          <img src="@/assets/images/u86.svg" alt="" @click="deleteTabelData" />
          <img src="@/assets/images/u88.svg" alt="" />
          <img src="@/assets/images/u89.svg" alt="" />
          <el-button size="mini" @click="btn">返回</el-button>
        </div>
      </div>
      <div class="content">
        <el-table :data="tableData" style="width: 100%; border-radius: 10px; height: 815px" border
          @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="116" align="center" />
          <el-table-column type="index" label="序号" align="center" width="116">
          </el-table-column>
          <el-table-column prop="roadId" label="道路名称" align="center">
          </el-table-column>
          <el-table-column prop="compositeGallery" label="综合管廊总长度" align="center">
          </el-table-column>
          <el-table-column prop="electricityGroove" label="电力沟总长度" align="center">
          </el-table-column>
          <el-table-column prop="electricityRow" label="电力排管总长度" align="center">
          </el-table-column>
          <el-table-column prop="rainwater" label="雨水管总长度" align="center">
          </el-table-column>
          <el-table-column prop="sewage" label="污水管总长度" align="center">
          </el-table-column>
          <el-table-column prop="reclaimedWater" label="中水管总长度" align="center">
          </el-table-column>
          <el-table-column prop="waterSupply" label="给水管总长度" align="center">
          </el-table-column>
          <el-table-column prop="fuelGas" label="燃气管总长度" align="center">
          </el-table-column>
          <el-table-column prop="heatingPower" label="热力管总长度" align="center">
          </el-table-column>
          <el-table-column prop="directDrinkingWater" label="直饮水管总长度" align="center">
          </el-table-column>
          <el-table-column prop="correspondence" label="通信揽管总长度" align="center">
          </el-table-column>
        </el-table>
      </div>
    <!-- </el-card> -->
    <div>
      <el-dialog title="新增廊管信息" :visible.sync="dialogVisible" :before-close="handleClose" :show-close="false">
        <el-form :inline="true">
          <el-form-item label="*道路名称" style="width: 352px">
            <el-select v-model="formData.roadId" placeholder="输入道路名称">
              <el-option v-for="item in options" :key="item.roadId" :label="item.roadName" :value="item.roadId">
              </el-option>
            </el-select>
            <div class="line"></div>
          </el-form-item>
          <el-form-item label="*综合廊管总长度（m）">
            <el-input placeholder="输入综合廊管总长度（m）" v-model="formData.compositeGallery"></el-input>
          </el-form-item>
          <el-form-item label="*电力沟总长度（m）">
            <el-input placeholder="输入电力沟总长度（m）" v-model="formData.electricityGroove"></el-input>
          </el-form-item>
          <el-form-item label="*电力排总长度（m）">
            <el-input placeholder="输入电力排总长度（m）" v-model="formData.electricityRow"></el-input>
          </el-form-item>
          <el-form-item label="*雨水管总长度（m）">
            <el-input placeholder="输入雨水管总长度（m）" v-model="formData.rainwater"></el-input>
          </el-form-item>
          <el-form-item label="*污水管总长度（m）">
            <el-input placeholder="输入污水管总长度（m）" v-model="formData.sewage"></el-input>
          </el-form-item>
          <el-form-item label="*中水管总长度（m）">
            <el-input placeholder="输入中水管总长度（m）" v-model="formData.reclaimedWater"></el-input>
          </el-form-item>
          <el-form-item label="*给水管总长度（m）">
            <el-input placeholder="输入给水管总长度（m）" v-model="formData.waterSupply"></el-input>
          </el-form-item>
          <el-form-item label="*燃气管总长度（m）">
            <el-input placeholder="输入燃气管总长度（m）" v-model="formData.fuelGas"></el-input>
          </el-form-item>
          <el-form-item label="*热力管总长度（m）">
            <el-input placeholder="输入热力管总长度（m）" v-model="formData.heatingPower"></el-input>
          </el-form-item>
          <el-form-item label="*直饮水管总长度（m）">
            <el-input placeholder="输入直饮水管总长度（m）" v-model="formData.directDrinkingWater"></el-input>
          </el-form-item>
          <el-form-item label="*通信揽管总长度（m）">
            <el-input placeholder="输入通信揽管总长度（m）" v-model="formData.correspondence"></el-input>
          </el-form-item>
        </el-form>
        <div class="dialog-footer">
          <el-button type="primary" @click="handleConfirm">提交</el-button>
          <el-button @click="dialogVisible = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import {
  getPipegalleryList,
  addPipegalleryList,
  getRoadList,
  deletaPipegalleryList
} from "@/api/collaborativeManagement";
export default {
  props: {
    id: {
      type: Number,
    },
  },
  data() {
    return {
      tableData: [
        {
          index: "1",
          roadname: "城市主干道",
        },
      ],
      input: "",
      queryForm: {
        pageSize: 10,
        pageNum: 1,
      },
      dialogVisible: false,
      options: [
        {
          value: "选项1",
          label: "道路1",
        },
        {
          value: "选项2",
          label: "道路2",
        },
        {
          value: "选项3",
          label: "道路3",
        },
        {
          value: "选项4",
          label: "道路4",
        },
      ],
      value: "",
      formData: {},
      ids: []
    };
  },
  mounted() {
    this.getTableList();
    this.getRoadTableList()
  },

  methods: {
    getTableList() {
      getPipegalleryList(this.queryForm).then((res) => {
        if (res.code == 200) {
          this.tableData = res.rows;
        }
      });
    },
    imgu87() {
      console.log(111);
      this.dialogVisible = true;
    },
    handleConfirm() {
      this.dialogVisible = false;
      this.formData["projectId"] = this.id;
      this.formData['remark'] = '123'
      this.formData['status'] = '1'
      addPipegalleryList(this.formData).then(res => {
        if (res.code == 200) {
          this.$message({
            type: 'success',
            message: '新增成功'
          });
          this.getTableList();
        }
      })

    },
    handleClose() { },
    btn() {
      this.$router.push("index");
    },
    //获取道路信息列表
    getRoadTableList() {
      let abc = {
        pageSize: 999,
        pageNum: 1,
        projectId: this.id
      }
      getRoadList(abc).then((res) => {

        if (res.code == 200) {
          this.options = res.rows;
        }
      });

    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.pipeGalleryId);
      console.log(this.ids, selection);

    },
    //删除数据
    deleteTabelData() {
      if (this.ids.length == 0) {
        this.$message({
          message: '请选择要删除的数据',
          type: 'warning'
        });
        return
      }



      this.$confirm("确认删除吗？")
        .then((_) => {
          this.ids.forEach(ele => {
            deletaPipegalleryList(ele)

          })
          setTimeout(() => {
            this.getTableList()
          }, 500);
          done();
        })
        .catch((_) => { });

    }
  },
};
</script>
<style lang="scss" scoped>
.box {

  // .el-card {
  //   height: 965px;
  // }
  .header {
    width: 100%;
    height: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .el-input {
      width: 50%;
    }

    .img {
      width: 200px;
      display: flex;
      justify-content: space-between;

      .el-button {
        background-color: rgb(178, 178, 179);
        color: #ffffff;
      }
    }

    ::v-deep .el-input__inner {
      width: 300px;
      height: 44px;
      border-radius: 10px;
      font-size: 14px;
      border-width: 1px;
      border-style: solid;
      border-color: rgba(215, 215, 215, 1);
    }

    .content {
      height: calc(100% - 60px);
    }
  }

  ::v-deep .el-dialog {
    width: 781px;
    height: 800px;
    border-radius: 20px;
    background-color: #f6f9fb;
    border: none;

    .el-dialog__title {
      font-weight: 650;
      font-size: 20px;
      display: flex;
      justify-content: center;
    }

    .el-form {
      margin-left: 60px;
      margin-top: -20px;

      .el-form-item__label {
        margin-left: 8px;
        margin-top: -10px;
      }

      .el-form-item {
        width: 310px;

        .el-input__inner {
          width: 300px;
          height: 44px;
          border-radius: 10px;
        }
      }

      .line {
        border-bottom: 1px solid red;
        width: 240px;
        margin-left: 30px;
      }
    }

    .dialog-footer {
      display: flex;
      justify-content: center;
      margin-top: 30px;

      >button:nth-of-type(1) {
        width: 633px;
        height: 54px;
        border-radius: 10px;
        position: absolute;
        bottom: 34px;
      }

      >button:nth-of-type(2) {
        width: 83px;
        height: 36px;
        border-radius: 10px;
        position: absolute;
        right: 15px;
        top: 15px;
      }
    }
  }
}
</style>
import { getPipegalleryList } from '../../api/collaborativeManagement';
